/* jshint indent: 2 */

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('user', {
    id: {
      type: DataTypes.STRING(50),
      allowNull: false,
      primaryKey: true
    },
    code: {
      type: DataTypes.STRING(50),
      allowNull: true,
      unique: true
    },
    nickname: {
      type: DataTypes.STRING(200),
      allowNull: false
    },
    session: {
      type: DataTypes.STRING(200),
      allowNull: false
    },
    avatarUrl: {
      type: DataTypes.STRING(500),
      allowNull: false
    },
    provincecode: {
      type: DataTypes.INTEGER(4).UNSIGNED,
      allowNull: true
    },
    province: {
      type: DataTypes.STRING(10),
      allowNull: true
    },
    carnumber: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    phone: {
      type: DataTypes.STRING(500),
      allowNull: true
    },
    money: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: '0.00'
    },
    status: {
      type: DataTypes.INTEGER(1).UNSIGNED.ZEROFILL,
      allowNull: false,
      defaultValue: '0'
    },
    formId: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    send: {
      type: DataTypes.INTEGER(1).UNSIGNED,
      allowNull: true,
      defaultValue: '0'
    },
    createdAt: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: sequelize.literal('CURRENT_TIMESTAMP')
    },
    updatedAt: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: sequelize.literal('CURRENT_TIMESTAMP')
    }
  }, {
    tableName: 'user'
  });
};
